package sesion;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.google.appengine.api.datastore.Key;
import entity.Korisnik;

public class KorisnikDaoJpa extends GenericJpaDao<Korisnik, Key> implements KorisnikDao{
	
	public Korisnik pronadjiKorisnika(String korisnickoIme,String sifra)
	{
		Korisnik korisnik=null;
		EntityManager em = null;
	    try {
	        em = emf.createEntityManager();
	        Query query = em.createQuery("select m from " + persistentClass.getSimpleName()+" m where m.koisnickoIme='"+korisnickoIme+"' and m.korisnickaSifra='"+sifra+"'");
	        korisnik=(Korisnik)query.getSingleResult();;
	    } catch (Exception ex) {
	        ex.printStackTrace();
	    }
	    finally
	    {
	    	if(em.isOpen())
	    	{
	    		em.close();
	        }
	    }
		return korisnik;
	}
}
